<template>
  <view class="filter-item">
    <view class="filter-title">{{ title }}</view>
    <view class="filter-list">
      <view
        :class="['tag', { active: item.label == label }]"
        v-for="(item, index) in list"
        :key="index"
        @click="handleClick(item)"
      >
        {{ item.label }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    label: {
      type: [String, Number],
      default: "",
    },
    title: String,
    list: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    handleClick(item) {
      this.$emit("change", item);
    },
  },
};
</script>

<style lang="scss" scoped>
.filter-item {
  margin-bottom: $uni-spacing-col-lg;
  .filter-title {
    padding: 20rpx 16rpx;
    font-size: 36rpx;
    font-weight: bold;
  }
}
.tag {
  display: inline-block;
  margin: 0 12rpx 32rpx;
  width: 207rpx;
  height: 56rpx;
  line-height: 56rpx;
  font-size: 12px;
  text-align: center;
  color: #333;
  border: 2rpx solid #d9d9d9;
  border-radius: 4rpx;
  background-color: $uni-bg-color-tag;
  &.active {
    color: $u-type-primary;
    border-color: $u-type-primary;
    background-color: $bg-color-button;
  }
}
</style>